<template>
  <view class="crowd-home-container">
    <view class="head px-2 box-border">
      <!-- 用户信息 -->
      <!-- 已登录 -->
      <template v-if="isLogin">
        <view class="user flex flex-row justify-between items-center py-4">
          <userOfTopLeft
            :userAvatar="userInfoStore.userInfo.userAavatar"
            :userName="userInfoStore.userInfo.userName"
            @onUserInfo="onPageJump('/subPages/crowd/mine/index')"
          ></userOfTopLeft>
          <view>
            <up-text
              prefixIcon="map-fill"
              :iconStyle="{ fontSize: '28rpx', color: '#fff' }"
              :text="
                userInfoStore.crowdInfo
                  ? userInfoStore.crowdInfo.communityName
                  : ''
              "
              color="#ffffff"
              size="25rpx"
            ></up-text>
          </view>
        </view>
      </template>
      <!-- 未登录 -->
      <template v-else>
        <view class="user flex flex-row justify-start items-center py-4">
          <userOfTopLeft
            userAvatar=""
            userName="未登录"
            :showMoreIcon="false"
            @onUserInfo="userRegister"
          ></userOfTopLeft>
        </view>
      </template>

      <!-- 轮播图 -->
      <view class="swiper">
        <up-swiper
          :list="swipers"
          circular
          @change="(e: any) => (current = e.current)"
          height="360rpx"
          radius="16rpx"
        >
          <template #indicator>
            <view class="indicator">
              <view
                class="indicator__dot"
                v-for="(item, index) in swipers"
                :key="index"
                :class="[index === current && 'indicator__dot--active']"
              >
              </view>
            </view>
          </template>
        </up-swiper>
      </view>
    </view>
    <view class="content px-2 box-border">
      <!-- 办事指南 -->
      <moduleOuterBox
        moduleTitle="业务办理"
        :moduleIcon="bsznIcon"
        :showMore="true"
        @onMoreBtn="onPageJump('/subPages/crowd/workGuide/home')"
      >
        <workGuideMenu
          :menuList="bsznMenu"
          @onWorkGuideMenuItem="workGuideItemDeatil"
        ></workGuideMenu>
      </moduleOuterBox>
      <!-- 互动专区 -->
      <moduleOuterBox moduleTitle="互动专区" :moduleIcon="hdzqIcon">
        <menuWithBg
          :menuList="hdzqMenu"
          @onMenuItem="onHdzqMenuItem"
        ></menuWithBg>
      </moduleOuterBox>
      <!-- ----------------------------------------------- -->
      <!-- ----------------------------------------------- -->
      <!-- ----------------------------------------------- -->
      <!-- ----------------------------------------------- -->
      <!-- ----------------------------------------------- -->
      <!-- ----------------------------------------------- -->
      <!-- ----------------------------------------------- -->
      <!-- ----------------------------------------------- -->
      <!-- ----------------------------------------------- -->
      <!-- ----------------------------------------------- -->
      <!-- ----------------------------------------------- -->
      <!-- ----------------------------------------------- -->
      <!-- ----------------------------------------------- -->
      <!-- ----------------------------------------------- -->
      <!-- ----------------------------------------------- -->
      <!-- ----------------------------------------------- -->
      <!-- ----------------------------------------------- -->
      <!-- ----------------------------------------------- -->
      <!-- ----------------------------------------------- -->
      <!-- ----------------------------------------------- -->
      <!-- ----------------------------------------------- -->
      <!-- bsznMenu             jwdtMenu -->
      <moduleOuterBox moduleTitle="警务大厅" :moduleIcon="hdzqIcon">
        <!-- <menuWithBg
          :menuList="jwdtMenu"
          @onMenuItem="onHdzqMenuItem"
        ></menuWithBg> -->
        <view class="mt-2.5">
          <personalModule
            :height="222"
            :leftWidth="170"
            :contentStyle="{ padding: '24rpx' }"
            showStatus
            showGapLine
            :statusBgColor="
              policeInfo != null && policeInfo.dutyStatus != 3
                ? '#33A954'
                : '#BBBBBB'
            "
            :statusName="
              policeInfo != null
                ? policeInfo.dutyStatus != 3
                  ? '在岗'
                  : ''
                : ''
            "
          >
            <!-- 已登录或定位在社区内 -->
            <!-- v-if="
              (isLogin || (ccInfo !== null && !ccInfo.withinFenceStatus)) &&
              policeInfo -->
            "
            <template v-if="isLogin && policeInfo">
              <template #left>
                <view
                  class="flex flex-col justify-between items-center text-center w-[100%] h-[100%]"
                >
                  <up-avatar
                    :src="imgPrefix + policeInfo.avatar"
                    shape="circle"
                    size="50"
                  ></up-avatar>
                  <text class="text-[25rpx] color-black">{{
                    policeInfo.communityName + "民警"
                  }}</text>
                  <view
                    @click="onPageJump('/subPages/crowd/policeStatus/index')"
                  >
                    <up-text
                      suffixIcon="arrow-right"
                      :iconStyle="{ color: '#000', fontSize: '20rpx' }"
                      text="更多"
                      color="#000000"
                      size="25rpx"
                    ></up-text>
                  </view>
                </view>
              </template>
              <template #right>
                <view
                  class="police-text text-[25rpx] color-black flex flex-col justify-between"
                >
                  <view
                    >姓名：<text class="font-bold">{{
                      policeInfo.userName
                    }}</text></view
                  >
                  <view>警号：{{ policeInfo.badgeNumber }}</view>
                  <view @click="callPhone(policeInfo.phonenumber)"
                    >电话：{{ policeInfo.phonenumber }}</view
                  >
                  <view
                    class="flex flex-row items-end"
                    @click="navPosition(policeInfo)"
                  >
                    <view
                      class="max-w-[92%] whitespace-nowrap text-ellipsis overflow-hidden"
                      >社区地址：{{ policeInfo.communitAddress }}</view
                    >
                    <image
                      class="w-[28rpx] h-[33rpx] ml-1"
                      :src="locationIcon"
                      mode="aspectFit"
                    ></image>
                  </view>
                </view>
              </template>
            </template>
            <!-- 未登录且定位在社区外 -->
            <template v-else>
              <template #left>
                <up-avatar
                  :src="chaoyangLogo"
                  shape="circle"
                  size="57"
                ></up-avatar>
              </template>
              <template #right>
                <view
                  class="police-text text-[25rpx] color-black flex flex-col justify-between"
                >
                  <view
                    ><text class="font-bold">{{
                      policePoiInfo.communityName
                    }}</text></view
                  >
                  <view @click="callPhone(policePoiInfo.tel)"
                    >电话：{{ policePoiInfo.tel }}</view
                  >
                  <view
                    class="flex flex-row items-end"
                    @click="navPosition(policePoiInfo)"
                  >
                    <view
                      class="max-w-[92%] whitespace-nowrap text-ellipsis overflow-hidden"
                      >社区地址：{{ policePoiInfo.communitAddress }}</view
                    >
                    <image
                      class="w-[28rpx] h-[33rpx] ml-1"
                      :src="locationIcon"
                      mode="aspectFit"
                    ></image>
                  </view>
                </view>
              </template>
            </template>
          </personalModule>
        </view>
        <view style="height: 20rpx"></view>
        <menuWithBg
          :menuList="jwdtMenu"
          @onMenuItem="onHdzqMenuItem"
        ></menuWithBg>
      </moduleOuterBox>
      <!-- ----------------------------------------------- -->
      <!-- ----------------------------------------------- -->
      <!-- ----------------------------------------------- -->
      <!-- ----------------------------------------------- -->
      <!-- ----------------------------------------------- -->
      <!-- ----------------------------------------------- -->
      <!-- ----------------------------------------------- -->
      <!-- ----------------------------------------------- -->
      <!-- ----------------------------------------------- -->
      <!-- ----------------------------------------------- -->
      <!-- ----------------------------------------------- -->
      <!-- ----------------------------------------------- -->
      <!-- ----------------------------------------------- -->
      <!-- ----------------------------------------------- -->
      <!-- ----------------------------------------------- -->
      <!-- ----------------------------------------------- -->
      <!-- ----------------------------------------------- -->
      <!-- ----------------------------------------------- -->
      <!-- ----------------------------------------------- -->
      <!-- ----------------------------------------------- -->
      <!-- ----------------------------------------------- -->
      <!-- ----------------------------------------------- -->
      <!-- ----------------------------------------------- -->
      <!-- ----------------------------------------------- -->
      <!-- ----------------------------------------------- -->
      <!-- ----------------------------------------------- -->
      <!-- ----------------------------------------------- -->
      <!-- ----------------------------------------------- -->
      <!-- ----------------------------------------------- -->
      <!-- ----------------------------------------------- -->
      <!-- ----------------------------------------------- -->

      <!-- 警务信息区域 -->
      <!-- <view class="mt-2.5">
        <personalModule
          :height="222"
          :leftWidth="170"
          :contentStyle="{ padding: '24rpx' }"
          showStatus
          showGapLine
          :statusBgColor="
            policeInfo != null && policeInfo.dutyStatus != 3
              ? '#33A954'
              : '#BBBBBB'
          "
          :statusName="
            policeInfo != null ? (policeInfo.dutyStatus != 3 ? '在岗' : '') : ''
          "
        >
          "
          <template v-if="isLogin && policeInfo">
            <template #left>
              <view
                class="flex flex-col justify-between items-center text-center w-[100%] h-[100%]"
              >
                <up-avatar
                  :src="imgPrefix + policeInfo.avatar"
                  shape="circle"
                  size="50"
                ></up-avatar>
                <text class="text-[25rpx] color-black">{{
                  policeInfo.communityName + "民警"
                }}</text>
                <view @click="onPageJump('/subPages/crowd/policeStatus/index')">
                  <up-text
                    suffixIcon="arrow-right"
                    :iconStyle="{ color: '#000', fontSize: '20rpx' }"
                    text="更多"
                    color="#000000"
                    size="25rpx"
                  ></up-text>
                </view>
              </view>
            </template>
            <template #right>
              <view
                class="police-text text-[25rpx] color-black flex flex-col justify-between"
              >
                <view
                  >姓名：<text class="font-bold">{{
                    policeInfo.userName
                  }}</text></view
                >
                <view>警号：{{ policeInfo.badgeNumber }}</view>
                <view @click="callPhone(policeInfo.phonenumber)"
                  >电话：{{ policeInfo.phonenumber }}</view
                >
                <view
                  class="flex flex-row items-end"
                  @click="navPosition(policeInfo)"
                >
                  <view
                    class="max-w-[92%] whitespace-nowrap text-ellipsis overflow-hidden"
                    >社区地址：{{ policeInfo.communitAddress }}</view
                  >
                  <image
                    class="w-[28rpx] h-[33rpx] ml-1"
                    :src="locationIcon"
                    mode="aspectFit"
                  ></image>
                </view>
              </view>
            </template>
          </template>
          <template v-else>
            <template #left>
              <up-avatar
                :src="chaoyangLogo"
                shape="circle"
                size="57"
              ></up-avatar>
            </template>
            <template #right>
              <view
                class="police-text text-[25rpx] color-black flex flex-col justify-between"
              >
                <view
                  ><text class="font-bold">{{
                    policePoiInfo.communityName
                  }}</text></view
                >
                <view @click="callPhone(policePoiInfo.tel)"
                  >电话：{{ policePoiInfo.tel }}</view
                >
                <view
                  class="flex flex-row items-end"
                  @click="navPosition(policePoiInfo)"
                >
                  <view
                    class="max-w-[92%] whitespace-nowrap text-ellipsis overflow-hidden"
                    >社区地址：{{ policePoiInfo.communitAddress }}</view
                  >
                  <image
                    class="w-[28rpx] h-[33rpx] ml-1"
                    :src="locationIcon"
                    mode="aspectFit"
                  ></image>
                </view>
              </view>
            </template>
          </template>
        </personalModule>
      </view> -->
      <!-- 新闻列表区域 -->
      <view class="part-box px-3 pb-3 box-border mt-2.5">
        <up-tabs
          :list="[
            { name: '反诈宣传' },
            { name: '消防安全' },
            { name: '防范提示' },
            { name: '政策规定' },
          ]"
          lineColor="#0A8CFE"
          lineWidth="70rpx"
          :activeStyle="{ color: '#0A8CFE', fontSize: '32rpx' }"
          :inactiveStyle="{ color: '#000', fontSize: '32rpx' }"
          :current="news.current"
          @click="
            (item, index) => {
              news.current = index;
              initNews();
            }
          "
          itemStyle="height: 70rpx;width:110rpx"
        >
          <!-- itemStyle="padding-left: 150px; padding-right: 15px; height: 34px;" -->
          <template #right>
            <view @click="onMoreNews">
              <up-text
                suffixIcon="arrow-right"
                :iconStyle="{ color: '#000', fontSize: '20rpx' }"
                text="更多"
                color="#000000"
                size="25rpx"
              ></up-text>
            </view>
          </template>
        </up-tabs>
        <view class="top-line mt-[-4rpx]"></view>
        <view class="px-2 box-border">
          <view
            class=""
            v-for="(item, index) in news.list"
            :key="item.id"
            @click="scanNewsDetail(item)"
          >
            <newsListItem
              :newsTitle="item.title"
              :newsTime="
                item.createTime
                  ? dayjs(item.createTime).format('YYYY-MM-DD')
                  : ''
              "
              :newsImg="imgPrefix + item.imgUrl"
            ></newsListItem>
          </view>
        </view>
      </view>

      <up-modal
        :show="showModal"
        title="提示"
        content="为保障您的账户安全，请先进行登录"
        contentTextAlign="center"
      >
        <template #confirmButton>
          <view class="flex flex-row justify-between item-center">
            <view class="w-[35%]">
              <up-button
                type="info"
                hairline
                text="取消"
                @click="showModal = false"
              ></up-button>
            </view>
            <view class="w-[35%]">
              <up-button
                type="primary"
                hairline
                text="去登录"
                open-type="getPhoneNumber"
                @getphonenumber="userRegister"
              ></up-button>
            </view>
          </view>
        </template>
      </up-modal>
      <up-gap height="16"></up-gap>

      <!-- <navigator 
    url="#小程序://一码游北碚/laDWOvXPZM3MAFE" 
    open-type="navigate"
  >
    点击打开「一码游北碚」小程序
  </navigator> -->

      <!-- const whzuix = () => {
  uni.navigateToMiniProgram({
    appId: "wx27b130aae926b62f",
    path: "/#小程序://一码游北碚/laDWOvXPZM3MAFE",
    // extraData: {
    //   data1: "test",
    // },
    success(res) {
      // 打开成功
      console.log(22)
      console.log(res)
    },
    fail(ree){
      console.log(333)
      console.log(ree)
    }
  }); -->
<view style="padding:20rpx;">
  <view @click="wewwtzd()"
        style="background: url('https://mscy.cqlandun.com:8088/static/ymy.png') no-repeat;height: 200rpx;background-size: 100% 100%;"
      ></view>
</view>
      

      <!-- <moduleOuterBox moduleTitle="文化寻踪" :moduleIcon="hdzqIcon"><view @click="wewwtzd()" style="background: url('http://gips3.baidu.com/it/u=3886271102,3123389489&fm=3028&app=3028&f=JPEG&fmt=auto?w=1280&h=960') no-repeat;height:200rpx;background-size: 100% 100%;"
        </view>
        
      </moduleOuterBox> -->

      <up-toast ref="uToastRef"></up-toast>
    </view>
  </view>
</template>

<script setup lang="ts">
import moduleOuterBox from "@/components/moduleOuterBox/moduleOuterBox.vue";
import workGuideMenu from "@/components/workGuideMenu/workGuideMenu.vue";
import menuWithBg from "@/components/menuWithBg/menuWithBg.vue";
import newsListItem from "@/components/newsListItem/newsListItem.vue";
import bsznIcon from "@/static/icon/bszn.png";
import hdzqIcon from "@/static/icon/hdzq.png";
import wfzjlzmIcon from "@/static/icon/wfzjlzm.png";
import jwrydjIcon from "@/static/icon/jwrydj.png";
import yqdjIcon from "@/static/icon/yqdj.png";
import locationIcon from "@/static/icon/location.png";
import chaoyangLogo from "@/static/icon/chaoyang.png";

import QQMapWX from "@/common/qqmap-wx-jssdk.js";
import { qqmapKey, imgPrefix } from "@/config/app";
import {
  callPhone,
  onPageJump,
  onLogin,
  getCrowdUserInfo,
} from "@/utils/tools";
import {
  listAntiFraud,
  listFireSafety,
  listPreventiveTip,
  regulationslistPage,
} from "@/api/news/index";
import { selectIndexPoliceUser } from "@/api/police/index";
import { workGuideOfHOme } from "@/api/workGuide/index";
import { getCommunityByPoint } from "@/api/user";

import dayjs from "dayjs";
import { useUserInfoStore } from "@/stores/userInfo";
const userInfoStore = useUserInfoStore();

const uToastRef = <any>ref(null);
const data = reactive({
  policeInfo: <any>null,
  news: {
    queryParams: {
      pageNum: 1,
      pageSize: 5,
    },
    current: 0,
    list: <any>[],
    request: [
      listAntiFraud,
      listFireSafety,
      listPreventiveTip,
      regulationslistPage,
    ],
  },
  bsznMenu: <any>[],
  hdzqMenu: [
    {
      title: "办事咨询",
      bgColor: "yellow",
    },
    {
      title: "服务评价",
      bgColor: "tangerine",
    },
    {
      title: "举报投诉",
      bgColor: "azure",
    },
    {
      title: "预约服务",
      bgColor: "yyfw",
    },
    {
      title: "隐患随手拍",
      bgColor: "yhsp",
    },
  ],
  jwdtMenu: [
    {
      title: "工作职责",
      bgColor: "gzzz",
    },
    {
      title: "服务承诺",
      bgColor: "fwcl",
    },
    {
      title: "数据驾驶舱",
      bgColor: "jsc",
    },
  ],
  showModal: false,
  isLogin: false,
  ccInfo: <any>ref(null), //群众所属社区信息
  policePoiInfo: {
    lat: 29.828773,
    lnt: 106.439854,
    tel: "(023)68316055",
    communityName: "朝阳派出所",
    communitAddress: "重庆市北碚区朝阳街道静宁路23号",
  },
});
const {
  policeInfo,
  news,
  bsznMenu,
  hdzqMenu,
  jwdtMenu,
  showModal,
  isLogin,
  ccInfo,
  policePoiInfo,
} = toRefs(data);
const current = ref(0);
const swipers = reactive([
  "https://mscy.cqlandun.com:8088/static/crowd-banner1.png",
  "https://mscy.cqlandun.com:8088/static/crowd-banner2.png",
  "https://mscy.cqlandun.com:8088/static/crowd-banner3.png",
]);
const userOfCrowdInfo = reactive(userInfoStore.crowdInfo);

// 获取用户所在位置
const getLocation = () => {
  // 实例化腾讯API核心类
  // let qqmapsdk = new QQMapWX({ key: qqmapKey });
  uni.getLocation({
    type: "gcj02",
    success: function (res) {
      getCommunityByPoint({ lat: res.latitude, lnt: res.longitude })
        .then((res1: any) => {
          const { data } = res1;
          ccInfo.value = data;
          if (data.withinFenceStatus) {
            getCommunityPolice(data.communityId);
          }
        })
        .catch((err: any) => {
          uToastRef.value.show({
            type: "error",
            message: err,
          });
        });
    },
    fail: function (err) {
      uToastRef.value.show({
        type: "error",
        message: "当前位置信息获取失败",
      });
    },
  });
};
// 用户授权登录，群众且注册
const userRegister = (e: any) => {
  showModal.value = false;
  onLogin(e, uToastRef);
};
// 初始化办事指南事项
const initWorkGuide = () => {
  workGuideOfHOme({
    pageNum: 1,
    pageSize: 3,
    queryType: 1,
  })
    .then((res: any) => {
      const { data } = res;
      data.records = data.records ?? [];
      if (data.records.length) {
        bsznMenu.value = data.records.map((item: any, index: number) => {
          item.icon = imgPrefix + item.logoUrl;
          item.title = item.itemName;
          if (index === 0) {
            item.bgOffset0 = "#fef9ec";
            item.bgOffset1 = "#fffcf7";
          }
          if (index === 1) {
            item.bgOffset0 = "#F6FFFD";
            item.bgOffset1 = "#F3FFFB";
          }
          if (index === 2) {
            item.bgOffset0 = "#ECF5FC";
            item.bgOffset1 = "#F4F8FB";
          }
          return item;
        });
      }
    })
    .catch((err: any) => {
      uToastRef.value.show({
        type: "error",
        message: err,
      });
    });
};
// 进入办事指南事项详情
const workGuideItemDeatil = (item: any) => {
  uni.navigateTo({
    url: `/subPages/crowd/workGuide/detail?id=${item.id}`,
  });
};
// 互动专区菜单点击
const onHdzqMenuItem = (item: any) => {
  if (userInfoStore.token && userInfoStore.openId) {
    if (item.title === "办事咨询") {
      uni.navigateTo({
        url: "/subPages/crowd/serviceConsultation/addConsultation",
      });
    }
    if (item.title === "服务评价") {
      uni.navigateTo({
        url: "/subPages/crowd/serviceEvaluation/addEvaluation",
      });
    }
    if (item.title === "举报投诉") {
      uni.navigateTo({
        url: "/subPages/crowd/reportComplaint/addComplaint",
      });
    }
    // 隐患随手拍
    if (item.title === "隐患随手拍") {
      uni.navigateTo({
        url: "/subPages/crowd/athand/addConsultation",
        // /subPages/crowd/serviceConsultation/addConsultation
      });
    }
    if (item.title === "预约服务") {
      uni.navigateTo({
        url: "/subPages/crowd/appointment/index",
        // /subPages/crowd/serviceConsultation/addConsultation
      });
    }
    // vvs

    // const onMoreNews = () => {
    //   let title = "";
    //   switch (news.value.current) {
    //     case 0:
    //       title = "反诈宣传";
    //       break;
    //     case 1:
    //       title = "消防安全";
    //       break;
    //     case 2:
    //       title = "防范提示";
    //       break;
    //     case 3:
    //       title = "政策规定";
    //       break;
    //     default:
    //       break;
    //   }
    //   uni.navigateTo({
    //     url: `/subPages/crowd/news/index?newsTitle=${title}`,
    //   });
    // };

    if (item.title === "工作职责") {
      // uni.navigateTo({
      //   url: "/subPages/crowd/reportComplaint/addComplaint",
      // });
      uni.navigateTo({
        // url: `/subPages/crowd/news/index?newsTitle=工作职责`,
		url: `/subPages/crowd/news/gzzz`,
      });
    }
    if (item.title === "服务承诺") {
      // uni.navigateTo({
      //   url: "/subPages/crowd/reportComplaint/addComplaint",
      // });
      uni.navigateTo({
        // url: `/subPages/crowd/news/index?newsTitle=服务承诺`,
		url: `/subPages/crowd/news/fwcr`,
      });
    }
    if (item.title === "数据驾驶舱") {
      uni.navigateTo({
        url: "/subPages/crowd/bgdata/index",
      });
    }
  } else {
    showModal.value = true;
  }
};
// 位置导航
const navPosition = (poiInfo: any) => {
  uni.openLocation({
    latitude: poiInfo.lat,
    longitude: poiInfo.lnt,
    scale: 18,
    name: poiInfo.communityName,
    address: poiInfo.communitAddress,
    success: function () {
      console.log("success");
    },
    fail: function (err) {
      console.log(err);
    },
  });
};
// 获取社区民警信息
const getCommunityPolice = (
  communityId: any = userInfoStore.crowdInfo.communityId
) => {
  selectIndexPoliceUser({ communityId })
    .then((res: any) => {
      const { data } = res;
      let arr = data ?? [];
      if (arr.length) policeInfo.value = arr[0];
    })
    .catch((err: any) => {
      uToastRef.value.show({
        type: "error",
        message: err,
      });
    });
};
// 初始化新闻列表
const initNews = () => {
  // news.current
  news.value.request[news.value.current](news.value.queryParams)
    .then((res: any) => {
      const { data } = res;
      news.value.list = data.records ?? [];
    })
    .catch((err: any) => {
      news.value.list = [];
      uToastRef.value.show({
        type: "error",
        message: err,
      });
    });
};
// 浏览更多新闻
const onMoreNews = () => {
  let title = "";
  switch (news.value.current) {
    case 0:
      title = "反诈宣传";
      break;
    case 1:
      title = "消防安全";
      break;
    case 2:
      title = "防范提示";
      break;
    case 3:
      title = "政策规定";
      break;
    default:
      break;
  }
  uni.navigateTo({
    url: `/subPages/crowd/news/index?newsTitle=${title}`,
  });
};
// 查看新闻详情
const scanNewsDetail = (item: any) => {
  uni.navigateTo({
    url: `/subPages/crowd/news/detail?newsId=${item.id}&newsType=${news.value.current}`,
  });
  // if (userInfoStore.token && userInfoStore.openId) {

  // } else {
  //   showModal.value = true;
  // }
};
// 查看新闻详情
const wewwtzd = (item: any) => {
  uni.navigateToMiniProgram({
    appId: "wx27b130aae926b62f",
    path: "#小程序://一码游北碚/laDWOvXPZM3MAFE",
    // extraData: {
    //   data1: "test",
    // },
    success(res) {
      // 打开成功
      console.log(22);
      console.log(res);
    },
    fail(ree) {
      console.log(333);
      console.log(ree);
    },
  });
  // uni.navigateTo({
  //   url: `/subPages/crowd/news/detail?newsId=${item.id}&newsType=${news.value.current}`,
  // });
  // if (userInfoStore.token && userInfoStore.openId) {

  // } else {
  //   showModal.value = true;
  // }
};

onLoad(async () => {
  initWorkGuide();
  initNews();
  // 用户已有注册账号信息
  if (
    userInfoStore.token &&
    userInfoStore.userInfo &&
    userInfoStore.userInfo.registerStatus == 1
  ) {
    isLogin.value = true;
    if (userInfoStore.userInfo.userType == 1) await getCrowdUserInfo(uToastRef);
  } else {
    // getLocation();
  }
});
watch(
  userInfoStore,
  (newVal, oldVal) => {
    if (newVal && newVal.crowdInfo) {
      getCommunityPolice(newVal.crowdInfo.communityId);
    }
  },
  {
    immediate: true,
    deep: true,
  }
);
onShareAppMessage((res) => {
  return {
    title: "码上朝阳",
    path: "/pages/crowd/home/index",
    imageUrl: "/static/logo.png",
    content: "我的码上朝阳小程序",
    mpId: "wxbaec7c3e7b23e9c4",
    type: 0,
  };
});
</script>

<style lang="scss" scoped>
.crowd-home-container {
  .head {
    background: linear-gradient(180deg, #0088fe 0%, #f4f5f9 100%);
  }
  .user {
    width: 100%;
    .right {
      width: 20%;
    }
  }
  .indicator {
    @include flex(row);
    justify-content: center;

    &__dot {
      height: 14rpx;
      width: 14rpx;
      border-radius: 100px;
      background-color: #eee;
      margin: 0 5px;
      transition: background-color 0.3s;

      &--active {
        background-color: #098cfe;
      }
    }
  }

  .swiper ::v-deep .u-swiper__wrapper__item__wrapper__title {
    background-color: transparent !important;
  }

  .police-text {
    width: calc(100% - 170rpx - 0.8rpx - 32rpx);
    height: 100%;
  }
  ::v-deep .u-tabs__wrapper__nav__item {
    padding: 0 30rpx;
  }
}
</style>
